#define _CRT_SECURE_NO_WARNINGS 1
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll cnt;
int main()
{
	int n;
	cin >> n;
	for (int i = 1; i < n; i++)
	{
		if (i * i % n < 1.0 / 2 * n)
			cnt++;
	}
	cout << cnt << endl;
	return 0;
}